﻿// -----------------------------------------------------------------------
// <copyright file="ExpressionEx.cs" company="none">
// Copyright (c) 2012 M. Alberti, xanatos(at)live.it
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
// </copyright>
// -----------------------------------------------------------------------

namespace FluentStatement
{
    using System.Linq.Expressions;

    /// <summary>
    /// 
    /// </summary>
    public static class ExpressionEx
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="condition"></param>
        /// <param name="body"></param>
        /// <param name="break"></param>
        /// <param name="continue"></param>
        /// <returns></returns>
        public static WhileExpression While(Expression condition, Expression body, LabelTarget @break = null, LabelTarget @continue = null)
        {
            return new WhileExpression(condition, body, @break, @continue);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="body"></param>
        /// <param name="condition"></param>
        /// <param name="break"></param>
        /// <param name="continue"></param>
        /// <returns></returns>
        public static DoWhileExpression DoWhile(Expression body, Expression condition, LabelTarget @break = null, LabelTarget @continue = null)
        {
            return new DoWhileExpression(body, condition, @break, @continue);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="body"></param>
        /// <param name="condition"></param>
        /// <param name="break"></param>
        /// <param name="continue"></param>
        /// <returns></returns>
        public static DoUntilExpression DoUntil(Expression body, Expression condition, LabelTarget @break = null, LabelTarget @continue = null)
        {
            return new DoUntilExpression(body, condition, @break, @continue);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="increment"></param>
        /// <param name="condition"></param>
        /// <param name="body"></param>
        /// <param name="break"></param>
        /// <param name="continue"></param>
        /// <returns></returns>
        public static ForExpression For(Expression increment, Expression condition, Expression body, LabelTarget @break = null, LabelTarget @continue = null)
        {
            return new ForExpression(increment, condition, body, @break, @continue);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="enumerable"></param>
        /// <param name="body"></param>
        /// <param name="break"></param>
        /// <param name="continue"></param>
        /// <returns></returns>
        public static ForEachExpression ForEach(Expression enumerable, LambdaExpression body, LabelTarget @break = null, LabelTarget @continue = null)
        {
            return new ForEachExpression(enumerable, body, @break, @continue);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="object"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        public static LockExpression Lock(Expression @object, Expression body)
        {
            return new LockExpression(@object, body);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="object"></param>
        /// <param name="timeout"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        public static TryLockExpression TryLock(Expression @object, Expression timeout, LambdaExpression body)
        {
            return new TryLockExpression(@object, timeout, body);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="object"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        public static UsingExpression Using(Expression @object, Expression body)
        {
            return new UsingExpression(@object, body);
        }
    }
}